package com.sms.gui.actions;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;

import com.sms.gui.SettingsDialog;
import com.sms.util.ResourcesHandler;

public class OkAction extends AbstractAction {

    private static final long serialVersionUID = 1L;
    private SettingsDialog dialog;

    public OkAction(SettingsDialog d) {
        super();
        dialog = d;
        putValue(AbstractAction.NAME, "Ok");
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        String usr = dialog.getUserField().getText();
        String pwd = dialog.getPasswordField().getText();
        if (usr != null && pwd != null) {
            ResourcesHandler.setUsername(usr);
            ResourcesHandler.setPassword(pwd);
            dialog.dispose();
        }
    }
}